package com.ghd.dataviz.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ghd.dataviz.core.param.BasePageParam;
import com.ghd.dataviz.core.param.PageInfo;
import lombok.SneakyThrows;
import org.apache.commons.beanutils.BeanUtils;

/**
 * @author ：ghd
 * @date ：Created in 2020-04-04 21:38
 * @description：分页参数转换工具
 * @modified By：
 * @version: $
 */
public class PageUtil {

    public static <T> Page<T> convertParam(BasePageParam pageParam) {
        return new Page<>(pageParam.getCurrent(), pageParam.getSize(), pageParam.getTotal());
    }

    @SneakyThrows
    public static <T> PageInfo<T> convertPage(Page<T> page) {
        PageInfo<T> pageInfo = new PageInfo<>();
        BeanUtils.copyProperties(pageInfo, page);
        return pageInfo;
    }
}
